import { defineStore } from 'pinia'
import { toRaw } from 'vue';
const useTheme = defineStore('useTheme', {
  state: () => ({
    currentTheme:JSON.parse(window.localStorage.getItem('theme') )||   {
        theme: 'light',
        title: '浅色模式',
        icon: 'theme-light'
      } ,
    count: 1,
    ThemeInfo: [
      {
        theme: 'light',
        title: '浅色模式',
        icon: 'theme-light'
      },
      {
        theme: 'dark',
        title: '深色模式',
        icon: 'theme-dark'
      },
      {
        theme: 'auto',
        title: '跟随系统',
        icon: 'theme-system'
      }
    ]
  }),
  actions: {
    changeTheme(theme) {
      this.currentTheme = theme
      console.log(this.currentTheme);
      
      window.localStorage.setItem('theme',JSON.stringify(toRaw(theme)))
    }
  }
})
export default useTheme
